﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.SECURITY.BLL;
using KPIS.GERP.SECURITY.MODEL;
using System.Data;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class Default : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            //    HttpCookie cookie = Request.Cookies["UserDetail"];
            //    if (cookie != null)
            //    {
            //        Session["EmpSeq"] = cookie["EmpSeq"];
            //        Session["UserName"] = cookie["UserName"];
            //        Session["UserSeq"] = cookie["UserSeq"];                    
            //    }
            //    else
            //    {
            //        string name = "3101200972795";
            //        string password = "1959";
            //        string UserStatus = "";

            //        DataRowCollection drc;

            //        drc = userBLL.Login(name, password).Tables[0].Rows;

            //        if (drc.Count > 0)
            //        {
            //            UserStatus = drc[0]["user_status"].ToString();

            //            if (UserStatus == SystemInfo._RegisterRecordStatus)
            //            {
            //                //RadManager1.Alert("รอการตรวจสอบจากผู้ดูแลระบบ");
            //                return;
            //            }
            //            else if (UserStatus == SystemInfo._WorkRecordStatus)
            //            {
            //                Session["EmpSeq"] = drc[0]["emp_seq"].ToString();
            //                Session["emp_seq"] = drc[0]["emp_seq"].ToString();
            //                Session["UserSeq"] = drc[0]["user_seq"].ToString();
            //                Session["UserCode"] = drc[0]["user_code"].ToString();
            //                //Page.Response.Redirect("Default.aspx");
            //            }
            //        }
            //    }

            //    KPIS.GERP.GHRMS.APP.Master mas = (Master)this.Master;
            //    mas.CreatedMenu(ssMng.UserSeq);
            //}
        }

        public void DemoCompareTwoTables()
        {
            // 1 Creating tables.
            DataTable dt1, dt2;
            Random r = new Random();
            dt1 = new DataTable();
            dt1.Columns.Add("id", typeof(int));
            dt1.Columns.Add("duplicated", typeof(string));
            dt2 = dt1.Clone(); // copy dt1's structure to dt2.

            // 2 Insert sample data
            dt1.Rows.Add(new object[] { 10, "N" });
            dt1.Rows.Add(new object[] { 20, "N" });
            dt1.Rows.Add(new object[] { 30, "N" });
            dt1.Rows.Add(new object[] { 40, "N" });
            dt2.Rows.Add(new object[] { 10, "N" });
            dt2.Rows.Add(new object[] { 30, "N" });
            dt2.Rows.Add(new object[] { 50, "N" });
            dt2.Rows.Add(new object[] { 70, "N" });

            // 3 Compare data (use dt1 as a base table)

            int count = 0;
            foreach (DataRow dr in dt1.Rows)
            {
                DataRow rowInDt2 = dt2.Rows.Find(dr["id"]);
                if (rowInDt2 != null)
                { // found it.
                    dr["duplicated"] = "Y";
                    count++;
                }
            }
        }

    }
}
